export function useTo(promise: any, errorExt?: any) {
  return promise
    .then((data: any) => {
      // console.log('to--->', data)
      return [null, data];
    })
    .catch((err: any) => {
      // console.log('err-->', err)

      if (errorExt) {
        Object.assign(err, errorExt);
      }

      return [err, undefined];
    });
}

export default useTo;
